package com.mynetwork.activity;

import java.util.ArrayList;

import com.mynetwork.R;
import com.mynetwork.data.ContentInfo;
import com.mynetwork.data.ContentManager;
import com.mynetwork.data.NetworkManager;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.RelativeLayout.LayoutParams;

public class SecondActivity extends FragmentActivity {

	public ArrayList<ContentInfo> mInfos;
	ContentInfo info;
	
	private View MapFragment = null;
	private View ListFragment = null;
	
	private LinearLayout menu_layout;
	
	private Button write_wanted;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.mainlayout);
		init();
		menu();
	}
	
//	private BitmapDownloadManager mBmpManager = new BitmapDownloadManager();
	
	private void init(){
		
		MapFragment = findViewById(R.id.map_fragment);
		ListFragment = findViewById(R.id.list_fragment);
		
		ListFragment.setVisibility(View.GONE);
				
		mInfos = ContentManager.getInstance().getContentList();
		
		RadioGroup radio_tap = (RadioGroup) findViewById(R.id.radio_tap);
		
		RadioGroup.OnCheckedChangeListener mtap = new RadioGroup.OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				switch (checkedId) {
				case R.id.radie_map:
					MapFragment.setVisibility(View.VISIBLE);
					ListFragment.setVisibility(View.GONE);
					break;
				case R.id.radie_list:
					MapFragment.setVisibility(View.GONE);
					ListFragment.setVisibility(View.VISIBLE);
					break;

				default:
					break;
				}
			}
		};
		radio_tap.setOnCheckedChangeListener(mtap);
	}
	
	private void menu(){
		menu_layout = (LinearLayout) findViewById(R.id.menu_layout);
		
		write_wanted = (Button) findViewById(R.id.write_wanted);
		
		write_wanted.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent i = new Intent(SecondActivity.this, WritewantedActivity.class);
				
				startActivity(i);
			}
		});
		
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		NetworkManager.listCount = 0;
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}
	
	
}
